originalInput = input("Введите скобочную последовательность: ")

def isBracket(char):
    if(char=="(" or char==")"
       or char=="[" or char=="]"
       or char=="{" or char=="}"
       or char=="<" or char==">"):
        return True
    return False

def isOpenedBracket(char):
    if char=="(" or char=="[" or char=="{" or char=="<":
        return True
    return False

def fromOpenedToClosed(char):
    if char=="(": return ")"
    elif char=="[": return "]"
    elif char=="{": return "}"
    elif char=="<": return ">"
    return False

onlyBrackets = []
opened = []
error = False

for i in originalInput:
    if(isBracket(i)):
        onlyBrackets.append(i)

for i in onlyBrackets:
    if isOpenedBracket(i):
        opened.append(fromOpenedToClosed(i))
    else:
        try:
            for j in range(''.join(opened).rindex(i), len(opened)):
                opened.pop(j)
        except:
            error = True
            break

if opened==[] and not error:
    print("True")
else:
    print("False")